<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var randomNum = Math.floor(Math.random() * 100)
    var isSuccess = false

    for (var i = 0; i < 7; i++) {
      var inputNum = Number(prompt("请输入您猜测是数字:"))
      if (inputNum === randomNum) {
        alert("猜对了")
        isSuccess = true
        break
      } else if (inputNum > randomNum) {
        alert("猜大了")
      } else {
        alert("猜小了")
      }
      if (i === 6) {
        alert("您的机会用完了")
      }
    }
    if (!isSuccess) {
      alert("您的机会用完了")
    }
  </script>
</body>

</html>